#!/bin/sh

findmnt --noheadings --pairs --output target,options --poll=mount \
| while read line; do
    # TARGET="..." OPTIONS="..."
    eval $line
    # NOTE: ignores mounts that were explicitly mounted with async
    if case "$TARGET" in /media/*) true;; *) false;; esac \
    && case "$OPTIONS" in *sync*) false;; *) true;; esac; then
        echo "mount -o remount,sync \"$TARGET\"" 1>&2
        mount --verbose -o remount,sync "$TARGET" 1>&2
    fi
done
